package com.kujie.ai.utils;

public class AnswerCleaner {

    /**
     * 清理answer内容，移除<think>标签及其内容
     *
     * @param answer 原始answer
     * @return 清理后的answer
     */
    public static String cleanAnswer(String answer) {
        if (answer == null || answer.isEmpty()) {
            return answer;
        }

        // 移除<think>标签
        String cleaned = answer.replaceAll("<think>", "\n\n").trim();

        // 移除<</think>>标签
        cleaned = cleaned.replaceAll("</think>", "\n\n").trim();

        // 移除多余的空行
        cleaned = cleaned.replaceAll("\n\\s*\n", "\n\n").trim();

        return cleaned;
    }
}
